<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@include file="connexion.jsp"%>

<%
	String ch = "", model = "", ch1 = "", ch2 = "";
	int relation, ra1, ra2;
	model = request.getParameter("model");
	ch = request.getParameter("cht");
	ch2 = request.getParameter("cht2");
	ch1 = request.getParameter("ch2");
	relation = Integer.parseInt(ch1);
	ra1 = Integer.parseInt(ch);
	ra2 = Integer.parseInt(ch2);
%>
<html>
<head>
<%@ page language="java" import="java.util.StringTokenizer"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<%
		Connection con = null;
		String URL = "jdbc:mysql://localhost:3306/" + model;
		//compter les ligne deja existantes
		con = DriverManager.getConnection(URL, "root", "metanote");
		int id_terme_contenu = 0;
		try {
			stmt = con.createStatement();
			ResultSet r = stmt
					.executeQuery("select max(id_terme_relation) from contenus_termes_relations");
			r.first();
			id_terme_contenu = r.getInt(1);
				}

		catch (Exception e) {
			out.println("une exception " + e.getMessage());
		}
		id_terme_contenu++;

		String req2 = "INSERT INTO contenus_termes_relations (id_terme_relation, id_contenu3, id_terme1, id_relation2) VALUES("
				+ id_terme_contenu
				+ ","
				+ ra1
				+ ","
				+ ra2
				+ ","
				+ relation
				+ ");";
		try {
			stmt.executeUpdate(req2);

		} catch (Exception ex) {
			out.println("Err" + ex.getMessage());
		}
		out.println("Insertion Effectuer ");
	%>
</body>
</html>